package com.mlnx.bptp.body;

public enum DeviceState {
    START_BP_DETECT(0x01, "关机"), STOP_BP_DETECT(0x02, "连接成功"), QUERY_DEVINFO(
            0x03, "进入休眠"), BP_DAY_DETECT(0x04, "唤醒");

    private int code;
    private String description;

    private DeviceState(int code, String description) {
        this.code = code;
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public static DeviceState decode(int code) {
        DeviceState[] deviceStates = DeviceState.values();
        for (int i = 0; i < deviceStates.length; i++) {
            if (code == deviceStates[i].code)
                return deviceStates[i];
        }
        return null;
    }
}
